package cn.tedu.web.entity;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 保存在订单中的临时订单
 * 
 * @author 王艳林
 * @email 981247127@qq.com
 * @time 2021-10-18 15:09:41
 **/
@Data
public class StorageOrder {
    /**
     * 订单细目
     */
    private List<OrderDetail> details;
    /**
     * 订单的收获地址
     */
    private Address address;
    /**
     * 订单总金额
     */
    private BigDecimal totalAmount;
    /**
     * 实际需要支付的金额
     */
    private BigDecimal paidAmount;
    /**
     * 优惠了多少钱？
     */
    private BigDecimal youhui;

    /**
     * 从临时存储的订单中提炼出订单对象
     */
    public Order getOrder(Integer uid) {
        Order order = new Order();
        order.setUid(uid);
        order.setTotalAmount(this.totalAmount);
        order.setPaidAmount(this.paidAmount);
        order.setYouhuiAmount(this.youhui);
        if (this.address != null) {
            order.setAddress(this.address.combine());
        }
        return order;
    }
}